<a name="titles"></a><h2><?php echo $row_courses['jiu_course_id']; ?> Module Overviews and Associated Titles</h2>
<?php do { 
$query_assignments = sprintf("SELECT * FROM assignments WHERE cid='%s' AND mid='%s' ORDER BY assign_num ASC", $cid, $row_modules['mid']);
	$assignments = mysql_query($query_assignments, $connection) or die(mysql_error());
	$row_assignments = mysql_fetch_assoc($assignments);
	
	$query_themes = sprintf("SELECT * FROM themes WHERE cid='%s' AND mid='%s' ORDER BY theme_num ASC", $cid, $row_modules['mid']);
	$themes = mysql_query($query_themes, $connection) or die(mysql_error());
	$row_themes = mysql_fetch_assoc($themes);
	$totalRows_themes = mysql_num_rows($themes);
?>
<table class="dataTable">
<tr>
	<th width="10%" nowrap="nowrap"><a name="<?php echo $row_modules['mid']; ?>"></a>Module <?php echo $row_modules['mid']; ?>:</th>
	<th colspan="2"><?php if ($row_modules['module_title'] != "") echo $row_modules['module_title']; else { ?><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span>No Title Entered<?php } ?></th>
    <th width="1%" nowrap="nowrap"><?php if ($modal_window != "true") { ?><span class="icon"><img src="images/page_edit.png" border="0" align="absmiddle" /></span><a <?php if ($section != "proposal_titles") echo "id=\"modal_window_link\""; ?> href="index.php?section=proposal_titles&amp;action=edit&amp;go=<?php echo $go; ?>&amp;view=proposal_detail&amp;dbTable=modules&amp;cid=<?php echo $cid; ?>&mid=<?php echo $row_modules['mid']; if ($section != "proposal_titles") echo "&amp;modal_window=true"; else echo "&amp;modal_window=false"; ?>">Edit Module <?php echo $row_modules['mid']; ?> Overview and Titles</a><?php } else echo "&nbsp;"; ?></th>
</tr>
	<tr style="background-color: <?php echo $color1; ?>">
        <td class="data" colspan="4"><strong>Overview</strong></td>
    </tr>
    <tr>
		<td class="data" colspan="4"><?php if ($row_modules['module_overview'] != "") echo $row_modules['module_overview']; else { ?><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span>No Overview Entered<?php } ?></td>
	</tr>
	<tr style="background-color: <?php echo $color1; ?>">
        <td class="data"><strong>Themes</strong></td>
        <td class="data">&nbsp;</td>
        <td class="data">&nbsp;</td>
        <td width="1%" nowrap="nowrap"><?php if ($modal_window != "true") { ?><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?section=proposal_titles&action=add&dbTable=themes&cid=<?php echo $cid; ?>','mid','<?php echo $row_modules['mid']; ?>','Are you sure you want to add a theme to Module <?php echo $row_modules['mid']; ?>?')">Add a Theme to Module <?php echo $row_modules['mid']; ?>?</a><?php } else echo "&nbsp;"; ?></td>
    </tr>
	<?php 		
			do { $d[] = $row_themes['theme_num']; } while ($row_themes = mysql_fetch_assoc($themes));
			sort($d);
			foreach (array_unique($d) as $value1) {
				$query_theme_loop = sprintf("SELECT * FROM themes WHERE cid='%s' AND mid='%s' AND theme_num='%s' ORDER BY vid DESC LIMIT 1", $cid, $row_modules['mid'], $value1);
				$theme_loop = mysql_query($query_theme_loop, $connection) or die(mysql_error());
				$row_theme_loop = mysql_fetch_assoc($theme_loop);
				$totalRows_theme_loop = mysql_num_rows($theme_loop);
			if ($totalRows_theme_loop > 0) { ?>
	<tr>
		<td class="data" nowrap="nowrap">Theme <?php echo $row_theme_loop['theme_num']; ?>:</td>
    	<td class="data" width="35%"><?php if ($row_theme_loop['theme_title'] != "") echo $row_theme_loop['theme_title']; else { ?><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span>No Title Entered<?php } ?></td>
        <td class="data"><?php if ($row_theme_loop['theme_num'] > "1") { ?><span class="icon"><img src="images/bin_closed.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?action=delete&dbTable=themes','id','<?php echo $row_theme_loop['id']; ?>','Are you sure want to delete Module <?php echo $row_modules['mid']; ?>, Theme <?php echo $row_theme_loop['theme_num']; ?>?')">Delete?</a><?php } else echo "&nbsp;"; ?></td>
        <td class="data">&nbsp;</td>
	</tr>
	<?php } } ?>
    <tr style="background-color: <?php echo $color1; ?>">
        <td class="data"><strong>Assignments</strong></td>
        <td class="data">&nbsp;</td>
        <td class="data">&nbsp;</td>
        <td width="1%" nowrap="nowrap"><?php if ($modal_window != "true") { ?><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?section=proposal_titles&action=add&dbTable=assignments&cid=<?php echo $cid; ?>','mid','<?php echo $row_modules['mid']; ?>','Are you sure you want to add an assignment to Module <?php echo $row_modules['mid']; ?>?')">Add an Assignment to Module <?php echo $row_modules['mid']; ?>?</a><?php } else echo "&nbsp;"; ?></td>
    </tr>
	<?php 		
			do { $d[] = $row_assignments['assign_num']; } while ($row_assignments = mysql_fetch_assoc($assignments));
			sort($d);
			foreach (array_unique($d) as $value1) {
				$query_assignment_loop = sprintf("SELECT * FROM assignments WHERE cid='%s' AND mid='%s' AND assign_num='%s' ORDER BY vid DESC LIMIT 1", $cid, $row_modules['mid'], $value1);
				$assignment_loop = mysql_query($query_assignment_loop, $connection) or die(mysql_error());
				$row_assignment_loop = mysql_fetch_assoc($assignment_loop);
				$totalRows_assignment_loop = mysql_num_rows($assignment_loop);
				
				$query_theme_comments = sprintf("SELECT * FROM comments WHERE cid='%s' AND tableName='themes' AND rid='%s'", $cid, $row_assignment_loop['id']);
				$theme_comments = mysql_query($query_theme_comments, $connection) or die(mysql_error());
				$row_theme_comments = mysql_fetch_assoc($theme_comments);
				$totalRows_theme_comments = mysql_num_rows($theme_comments);
				
				if ($totalRows_assignment_loop > 0) { ?>
	<tr>
		<td class="data" nowrap="nowrap">Assignment <?php echo $row_modules['mid'].".".$row_assignment_loop['assign_num']; ?>:</td>
       	<td class="data" width="35%"><?php echo $row_assignment_loop['assign_title']; $check1 = ltrim($row_assignment_loop['assign_title'],"Course Project -"); $check2 = ltrim($row_assignment_loop['assign_title'],"Discussion -"); if (($check1 == "") || ($check2 == "")) { ?><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span>No Title Entered<?php } ?></td>
        <td class="data"><?php if ($row_assignment_loop['assign_num'] > "2") { ?><span class="icon"><img src="images/bin_closed.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?action=delete&dbTable=assignments','id','<?php echo $row_assignment_loop['id']; ?>','Are you sure want to delete Module <?php echo $row_modules['mid']; ?>, Assignment <?php echo $row_modules['mid'].".".$row_assignment_loop['assign_num']; ?>?')">Delete?</a><?php } else echo "&nbsp;"; ?></td>
        <td class="data">&nbsp;</td>
	</tr>
	<?php } } ?>
</table>
<br />
<?php } while ($row_modules = mysql_fetch_assoc($modules)); ?>
